package com.credit.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.credit.common.ServerResponse;
import com.credit.pojo.balanceSheet;
import com.credit.pojo.flows;
import com.credit.pojo.profit;
import com.credit.service.IFinanceService;
import com.credit.vo.YearVo;

/**
 * 财务信息
 * @author Administrator
 *
 */
@CrossOrigin(origins = "*", maxAge = 3600)//跨越请求配置
@RestController
@Controller
public class FinanceController {

	@Autowired
	private IFinanceService financeService;
	
	/**
	 * 资产负债增加
	 * @param b
	 * @return
	 */
	@RequestMapping(value = "addBalanceSheet.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse addBalanceSheet(balanceSheet b) {
		
		return financeService.insertBalanceSheet(b);
	}
	
	/**
	 * 资产负债修改
	 * @param b
	 * @return
	 */
	@RequestMapping(value = "upBalanceSheet.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse upBalanceSheet(balanceSheet b) {
		
		return financeService.updateBalanceSheet(b);
	}
	
	/**
	 * 资产负债查询
	 * @param y
	 * @return
	 */
	@RequestMapping(value = "selectBalanceSheet.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse selectBalanceSheet(YearVo y) {
		
		return financeService.BalanceSheet(y);
	}
	
	
	
	
	
	/**
	 * 现金流量增加
	 * @param f
	 * @return
	 */
	@RequestMapping(value = "addFlows.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse addFlows(flows f) {
		
		return financeService.insertFlows(f);
	}
	
	/**
	 * 现金流量修改
	 * @param f
	 * @return
	 */
	@RequestMapping(value = "upFlows.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse upFlows(flows f) {
		
		return financeService.updateFlows(f);
	}
	
	/**
	 * 现金流量查询
	 * @param y
	 * @return
	 */
	@RequestMapping(value = "selectFlows.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse selectFlows(YearVo y) {
		
		return financeService.selectFlows(y);
	}
	
	
	
	
	
	
	/**
	 * 利润增加
	 * @param p
	 * @return
	 */
	@RequestMapping(value = "addProfit.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse addProfit(profit p) {
		
		return financeService.insertProfit(p);
	}
	
	/**
	 * 利润修改
	 * @param p
	 * @return
	 */
	@RequestMapping(value = "upProfit.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse upProfit(profit p) {
		
		return financeService.updateProfit(p);
	}
	
	/**
	 * 利润查看
	 * @param y
	 * @return
	 */
	@RequestMapping(value = "selectProfit.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse selectProfit(YearVo y) {
		
		return financeService.selectProfit(y);
	}
}
